<?php

class Language_controller extends CI_Controller {
    
    function Language_controller() {
        parent::__construct();
        
        $this->load->model('Language_model');
    }
    
    public function index() {        
        $this->load->library('session');
        $data['lang'] = $this->session->userdata('lang');
        $data['member_id'] = $this->session->userdata('member_id');
        $data['firstname'] = $this->session->userdata('firstname');        
        $this->load->model('Panel_model');
        $data['panel'] = $this->Panel_model->admin_menus_list();
        foreach ($data['panel'] as $key => $option) {
            $data['panel'][$key]['option'] = $this->Panel_model->admin_options_list($option['admin_panel_id']);
        }       
        
        $data['route'] = 'languages';
        $data['languages'] = $this->Language_model->languages_list();
        
        $this->load->view('layout/admin', $data);
    }
    
    public function set() {
        $data = $this->input->post();
        
        $language_id = $this->Language_model->language_set($data['name']);
        
        // restaurant customization
        $this->load->model('Menu_model');
        // hard code
        $this->Menu_model->menu_root_set($language_id[0], $data['name'], $data['name']);
               
        $this->index();
    }
    
    public function delete($language_id) {
        $this->Language_model->language_delete($language_id);
        
        $this->index();
    }
    
}

?>